package com.zzc.study.controller;

import dev.langchain4j.model.chat.ChatLanguageModel;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther zzyybs@126.com
 * @Date 2025-05-02 11:41
 * @Description: https://docs.langchain4j.dev/tutorials/spring-boot-integration
 */
@RestController
@Slf4j
public class PopularIntegrationsController
{
    @Resource(name = "qwen")
    private ChatLanguageModel chatLanguageModelQwen;
    @Resource(name = "deepseek")
    private ChatLanguageModel chatLanguageModelDeepSeek;

    //http://localhost:9012/chatapi/chatApi01
    @GetMapping(value = "/chatapi/chatApi01")
    public String chatApi01(@RequestParam(value = "prompt", defaultValue = "你是谁") String prompt)
    {
        String result = chatLanguageModelQwen.chat(prompt);

        System.out.println("通过langchain4j调用qwen模型返回结果：\n"+result);

        return result;

    }

    //http://localhost:9012/chatapi/chatApi02
    @GetMapping(value = "/chatapi/chatApi02")
    public String chatApi02(@RequestParam(value = "prompt", defaultValue = "你是谁") String prompt)
    {
        String result = chatLanguageModelDeepSeek.chat(prompt);

        System.out.println("通过langchain4j调用deepseek模型返回结果：\n"+result);

        return result;

    }
}
